23. HAVING
SOLUTION:
- **WHERE** subsets the returned data based on a logical condition.
- **WHERE** appears after the **FROM**, **JOIN**, and **ON** clauses, but before **GROUP BY**.
- **HAVING** appears after the **GROUP BY** clause, but before the **ORDER BY** clause.
- **HAVING** is like **WHERE**, but it works on logical statements involving aggregations.
Questions: HAVING
Use the SQL environment below to assist with answering the following questions. Whether you get stuck or you just want to double check your solutions, my answers can be found at the top of the next concept.
How many of the sales reps have more than 5 accounts that they manage?
How many accounts have more than 20 orders?
Which account has the most orders?
Which accounts spent more than 30,000 usd total across all orders?
Which accounts spent less than 1,000 usd total across all orders?
Which account has spent the most with us?
Which account has spent the least with us?
Which accounts used
facebook
as a channel to contact customers more than 6 times?Which account used
facebook
most as a channel?Which channel was most frequently used by most accounts?
Code
If you need a code on the https://github.com/udacity.